package org.wishwork.api.base.logistics;

import cn.hutool.core.util.StrUtil;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.ExtendBase;
import org.wishwork.exception.ExceptionEnum;
import org.wishwork.exception.JSTException;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

/**
 * @description: 物流请求体
 * @author: WangYX
 * @create: 2022-04-02 17:31
 * @Version: 1.0.0
 **/
@EqualsAndHashCode
@Getter
@ToString
public class LogisticsRequest extends ExtendBase {

    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    /**
     * 非必填
     * 公司编号，该值存在时查询对应公司或分仓下的启用的物流公司信息，否则查询系统内所有的物流公司信息
     */
    private Integer wmsCoId;

    public LogisticsRequest(Integer pageIndex, Integer pageSize, String modifiedBegin, String modifiedEnd, Integer wmsCoId) {
        super(pageIndex, pageSize, modifiedBegin, modifiedEnd);
        this.wmsCoId = wmsCoId;
    }

    public static Builder builder() {
        return new Builder();
    }

    @Override
    public Builder toBuilder() {
        return new Builder().wmsCoId(this.wmsCoId).pageIndex(this.pageIndex).pageSize(this.pageSize).modifiedBegin(this.modifiedBegin).modifiedEnd(this.modifiedEnd);
    }

    public static class Builder extends ExtendBase.Builder<Builder, LogisticsRequest> {

        private Integer wmsCoId;

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        @Override
        public Builder modifiedBegin(String modifiedBegin) {
            this.modifiedBegin = modifiedBegin;
            return this;
        }

        @Override
        public Builder modifiedEnd(String modifiedEnd) {
            this.modifiedEnd = modifiedEnd;
            return this;
        }

        public Builder wmsCoId(Integer wmsCoId) {
            this.wmsCoId = wmsCoId;
            return this;
        }

        @Override
        public LogisticsRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageIndex < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 30 : this.pageSize < 0 ? 30 : this.pageSize;
            return new LogisticsRequest(this.pageIndex, this.pageSize, this.modifiedBegin, this.modifiedEnd, this.wmsCoId);
        }
    }
}
